package com.lin.manager.pay.service;

import com.lin.manager.pay.model.dto.PayDto;
import org.springframework.util.StringUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @作者: 林江
 * @创建时间: 2024/4/21
 * @功能:
 */
public class PayService implements Pay {
    Map<String, Pay> payMap = new ConcurrentHashMap<>();

    public Map<String, Pay> getPayMap() {
        return payMap;
    }

    public void setPayMap(Map<String, Pay> payMap) {
        this.payMap = payMap;
    }

    @Override
    public void pay(PayDto dto) {
        Pay pay;
        if (StringUtils.hasText(dto.getType()) &&
                (pay = payMap.get(dto.getType())) != null) {
            pay.pay(dto);
        } else {
            throw new RuntimeException("未配置此种支付方式");
        }
    }

    @Override
    public void query() {

    }

    @Override
    public void close() {

    }

    @Override
    public void refund() {

    }

    @Override
    public void refundQuery() {

    }
}
